package Perception;

import java.util.HashMap;
import java.util.ArrayList;
import java.util.Collection;
import Perception.Percepts;
/**
 * TODO description
 */
public class PerceptsBase {

	HashMap <String,ArrayList<Percepts>> table;
	
	public PerceptsBase ()
	{
		table = new HashMap<String,ArrayList<Percepts>>();
	}
	
	public void addPercept(Percepts p)
	{
		if(table.containsKey(p.getName()))
			((table.get(p.getName()))).add(p);
		else
		{
			ArrayList<Percepts> list = new ArrayList<Percepts>();
			list.add(p);
			table.put(p.getName(), list);
		}
	}
	
	public ArrayList<Percepts> getPercepts(String name)
	{
		if(table.containsKey(name))
			return table.get(name);
		return null;
	}
	
	public void removePercepts(String name)
	{
		if(table.containsKey(name))
			table.remove(name);
	}
	
	public boolean perceptsExists(String name)
	{
		return table.containsKey(name);
	}
	
	public void clear()
	{
		table.clear();
	}
	
	public Collection<ArrayList<Percepts>> getAllPercept()
	{
		return table.values();
	}
}